#include<iostream>
#include<stdlib.h>
#include<cstring>
#include<algorithm>

using namespace std;

const int Max = 1000000001;

int t ,n , m , a , b ,len ,start ,end,vertex;
int dist[101][101],path[101][101],route[101],branch[101];
int h , i , j  , k , l ,p ,q;

void Root(int p,int q)
{
    if (path[p][q]>0)
    {
        Root(p,path[p][q]);
        Root(path[p][q],q);
    }
    else
    {
        route[k]=q;
        k++;
    }
}

bool fun( int *a ,int n)
{
    int i , j ,k;
    bool flag = false;
    for( i = 0 ; i <= n ; i++ )     
    {
      for( j = i+1 ; j <= n ; j++ )
      {
        for( k = j+1; k <= n ; k++ )    
        {
            if( a[i]+a[j] > a[k] ) { flag = true; break; }
        }  
        if( flag ) break;
      }
      if( flag ) break;
    }
    if( flag )  return true;
    else return false;
}

int cmp(  const void *a , const void *b  )
{
    return *(int *)a-*(int *)b;     
}

int main()
{
    cin>>t;
    for( i = 0 ; i < t ; i++ )    
    {
        memset(dist , 0 , sizeof(dist) );
        memset(path , 0 , sizeof(path) );
        memset(route, 0 , sizeof(route));
        memset(branch,0 , sizeof(branch));
        
        cin>>vertex;
        for( j = 1 ; j <= vertex-1 ; j++ )//n-1 edges 
        {
            cin>>a>>b>>len;     
            dist[a][b] = len;
            dist[b][a] = len;
        }
        
        /* calculate the shortest path using floyd */
        for( k = 1 ; k <= vertex ; k++ )
          for( p = 1 ; p <= vertex ; p++ )
          { 
              if (dist[p][k]>0)
              for( q = 1 ; q <= vertex ; q++ )
              {
                  if (dist[k][q]>0)
                  {
                      if (((dist[p][q]>dist[p][k]+dist[k][q])||(dist[p][q]==0))&&(p!=q))
                      {
                          dist[p][q]=dist[p][k]+dist[k][q];
                          path[p][q]=k;
                      }
                  }//if
          }//for
        }//for 
        
        cout<<"Case #"<<i+1<<":"<<endl;
        /* find the path from point a to  point b */
        cin>>m;
        for( j = 0 ; j < m ; j++ )
        {
            cin>>start>>end;     
            k = 2 ;
            Root(start,end);
            route[1] = start;
            for( h = 1; h<k-1 ; h++ )                       //there are k-1 nodes : route[1]...route[n-1]
              branch[h] = dist[ route[h] ][ route[h+1] ];   //there are k-2 edges,calculate the length of each branch.
                
            /* calculate that whether the trees can form triangle */
            if( k-2<=2 )   cout<<"No"<<endl;
            else
            {
                sort( branch+1,branch+k-1 );
                if( fun(branch,k-2) )  cout<<"Yes"<<endl;
                else cout<<"No"<<endl;
            }
        }
    }//for 
    
    system("pause");
    return 0 ;
} 
